/*
	Copyright (C) 2008 Demiurg-HG
	
	This program is free software; you can redistribute it and/or
	modify it under the terms of the GNU General Public License
	as published by the Free Software Foundation; either version 2
	of the License, or (at your option) any later version.
	
	This program is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU General Public License for more details.
	
	You should have received a copy of the GNU General Public License
	along with this program; if not, write to the Free Software
	Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
*/
// i_ui.h - 

const uint UI_MOUSE_LEFT	=	0x0001;
const uint UI_MOUSE_RIGHT	=	0x0002;
const uint UI_MOUSE_MIDDLE	=	0x0004;

const uint UI_ALIGNH_LEFT	=	0x0001;
const uint UI_ALIGNH_RIGHT	=	0x0002;
const uint UI_ALIGNH_CENTER	=	0x0004;
const uint UI_ALIGNH_FILL	=	0x0008;

const uint UI_ALIGNV_TOP	=	0x0010;
const uint UI_ALIGNV_BOTTOM	=	0x0020;
const uint UI_ALIGNV_CENTER	=	0x0040;
const uint UI_ALIGNV_FILL	=	0x0080;

struct uiRect_s {
		uiRect_s(void) { x = y = w = h = 0; }
		uiRect_s(float x, float y, float w, float h) {
			this->x = x;	this->y = y;
			this->w = w;	this->h = h;
		}
		float x, y, w, h;
	};



interface IFont {
		virtual				~IFont			( void ) {}
		virtual const char	*Name			( void ) const = 0;
		virtual const char	*GetFontImage	( void ) const = 0;
		virtual float		GetLineHeight	( void ) const = 0;
		virtual float		GetBaseLine		( void ) const = 0;
						
		virtual float		GetXAdvance		( uchar ch ) const = 0;
		virtual EVec2		GetOffset		( uchar ch ) const = 0;
		virtual EVec2		GetUV0			( uchar ch ) const = 0;
		virtual EVec2		GetUV1			( uchar ch ) const = 0;
		virtual EVec2		GetGlyphSize	( uchar ch ) const = 0;
		virtual float		GetKerning		( uchar first, char second ) const = 0;
	};
	

interface IUIFrame {
		virtual				~IUIFrame			( void ) {};

		//	Message stuff :		
		virtual void		FMKeyPress			( uint code ) = 0;
		virtual void		FMKeyDown			( uint code ) = 0;
		virtual void		FMPaint				( void ) = 0;
		virtual void		FMMouseUp			( uint button, float x, float y ) = 0;
		virtual void		FMMouseDown			( uint button, float x, float y ) = 0;
		virtual void		FMMouseClick		( uint button, float x, float y ) = 0;
		virtual void		FMMouseIn			( void ) = 0;
		virtual void		FMMouseOut			( void ) = 0;
		virtual void		FMMouseMove			( uint button, float x, float y ) = 0;
		virtual void		FMProcess			( float delta, float time ) = 0;
		virtual void		FMResize			( float new_width, float new_height ) = 0;
		virtual void		FMMove				( float new_x, float new_y ) = 0;
		virtual	void		FMShowFrame			( void ) = 0;
		virtual void		FMHideFrame			( void ) = 0;
		
		//	Frame property stuff :
		virtual IUIFrame	*GetClientArea		( void ) = 0;
		virtual bool		IsVisible			( void ) const = 0;
		virtual bool		IsEnabled			( void ) const = 0;
		virtual bool		IsDraggable			( void ) const = 0;
		virtual bool		IsSizeable			( void ) const = 0;
		virtual uiRect_s	GetFrameRect		( void ) const = 0;
		virtual float		GetFrameOpacity		( void ) const = 0;
		virtual void		GetScrollOffset		( float &dx, float &dy ) = 0;
		virtual const char	*GetFrameText		( void ) const = 0;
	};


interface IUIHook {
		virtual				~IUIHook	( void ) {}
		virtual void		Hook		( uint code  ) = 0;
		virtual	uint		GetHook		( void ) = 0;
		virtual	IUIFrame	*GetFrame	( void ) = 0;
		virtual	void		Clear		( void ) = 0;
	};


interface	IUserInterface {
		virtual				~IUserInterface		( void ) {}
						
		//	UI rendering API :
		virtual void		DrawStringMT		( float x, float y, float size, float tracking, const char *font_raster, const char *string, const EVec4 &color ) = 0;
		virtual void		DrawStringMTClr		( float x, float y, float size, float tracking, const char *font_raster, const char *string ) = 0;
		virtual void		DrawStringFont		( float x, float y, const IFont *font, const char *string, const EVec4 &color=EVec4(1,1,1,1) ) = 0;
		virtual void		DrawTextInRect		( uiRect_s &r, const IFont *font, const char *text, uint align, const EVec4 &color=EVec4(1,1,1,1) ) = 0;
		virtual float		StringFontLength	( const IFont *font, const char *string ) = 0;
		virtual void		DrawRect			( float x, float y, float w, float h, const char *image, const EVec4 &color ) = 0;
		virtual void		DrawBorderRect		( float x, float y, float w, float h, const char *image, const EVec4 &color ) = 0;
		virtual void		DrawBorderRectTop	( float x, float y, float w, float h, const char *image, const EVec4 &color ) = 0;
		virtual void		DrawBorderRectBottom( float x, float y, float w, float h, const char *image, const EVec4 &color ) = 0;
		virtual IFont		*RegisterFont		( const char *path ) = 0;

		//	UI frame management :
		virtual void		AttachFrame			( IUIFrame *parent, IUIFrame *frame ) = 0;
		virtual void		DetachFrame			( IUIFrame *frame ) = 0;
		virtual uint		GetFrameChildNum	( IUIFrame *frame ) = 0;
		virtual IUIFrame	*GetFrameChild		( IUIFrame *frame, uint n ) = 0;
		virtual IUIFrame	*GetFrameParent		( IUIFrame *frame ) = 0;

		virtual void		SetForegroundFrame	( IUIFrame *frame ) = 0;
		virtual void		SetActiveFrame		( IUIFrame *frame ) = 0;
		virtual void		ShowFrame			( IUIFrame *frame ) = 0;
		virtual void		HideFrame			( IUIFrame *frame ) = 0;
		virtual uiRect_s	GetDragRect			( void ) = 0;
		virtual IUIFrame	*GetDraggingFrame	( void ) = 0;
		virtual IUIFrame	*GetFrameUnderCursor( void ) = 0;
		virtual IUIFrame	*GetActiveFrame		( void ) = 0;
		virtual void		RenderFrames		( void ) = 0;
		virtual void		ProcessFrames		( void ) = 0;
		virtual void		GetAbsolutePosition	( IUIFrame *frame, float &x, float &y ) = 0;
		
		//	UI feedback stuff :		
		virtual void		KeyPress			( uint code ) = 0;
		virtual void		KeyDown				( uint code ) = 0;
		virtual void		MouseMove			( const mouseInput_s *mouse_input ) = 0;
		
		//	UI hook stuff :	
		virtual IUIHook	*	GetKeyboardHook			( void ) = 0;
		virtual void		SetKeyboardHook			( IUIHook * hook ) = 0;
		virtual IUIHook	*	GetMouseHook			( void ) = 0;
		virtual void		SetMouseHook			( IUIHook * hook ) = 0;
	};
	
	
	
	
	